The goal of Redis is to be concise and efficient, because the transaction itself is a complex thing, and all we can't do is complicate the transaction ...
multi,exec
127.0.0.1:6379> multi
OK
127.0.0.1:6379> lpush fruits orange
QUEUED
127.0.0.1:6379> lpush fruits nut
QUEUED
127.0.0.1:6379> lpush fruits apple
QUEUED
127.0.0.1:
Redis Services (transaction)
This document is translated from: Http://redis.io/topics/transactions.
MULTI, EXEC, discard and WATCH are the basis of the Redis transaction.
A transaction can execute more than one command at a time with the following two important guarantees:
A
I. Overview: Like many other databases, Redis also provides a transaction mechanism as a NoSQL database. In Redis, the four commands MULTIEXECDISCARDWATCH are the cornerstone for implementing transactions. I believe this concept is no stranger to developers with relational database development experience. Even so, we will briefly list things in
I. Overview:
Like many other databases, redis also provides a transaction mechanism as a nosql database. In redis, the four commands multi/exec/discard/watch are the cornerstone of our transaction implementation. I believe this concept is no stranger to developers with relational database development experience. Even
Related commands: DISCARD EXEC MULTI unwatch WATCH transaction
Multi,exec,discard and watch are the basis of Redis transactions. They allow a set of commands to be executed in one step, with two important guarantees: All commands in the transaction are serialized and executed sequentially. In the process of performing a redis
Redis Transaction Processing
Current redis version# Redis-cli-vRedis-cli 2.6.4
MULTI, EXEC, DISCARD, and WATCH are the foundation of Redis transactions.
1. The MULTI command is used to start a transaction. It always returns OK.Aft
Reproduced in: http://www.itxuexiwang.com/a/shujukujishu/redis/2016/0216/135.html?1455806987First, overview:Like many other databases, Redis also provides a transactional mechanism as a NoSQL database. In Redis, the multi/exec/discard/watch of these four commands is the cornerstone of our implementation of a transaction
DISCARD
Cancels the transaction, discarding all commands within the transaction block.If you are using the Watch command to monitor a (or some) key, then canceling all monitoring is equivalent to executing command unwatch.Available Versions:2.0.0+complexity of Time:O (1).return Value:Always return OK.
redis> MULTI
OK
redis
Analysis of Redis transaction and improvement of the transaction characteristics of RedisHow many of the data acid properties are met?To keep it simple, Redis transactions guarantee consistency and isolation;Not satisfying atomicity and permanence;Atomic NatureRedis transaction
transaction and discard all commands of the transaction block. If you are using watch monitoring, all monitoring will be canceled.Time Complexity: O (1)Return Value: Always Returns OK
WatchFormat: wathc key [key...]Specifies the KEY (multiple keys) to be monitored. If this (or these) key is changed by other commands before the transaction is executed, the
The Redis transaction mechanism, in other databases such as MySQL, represents a set of actions that are either all executed or not executed. This paper mainly introduces the transaction mechanism in Redis and the related content of optimistic lock, through the execution of the tran
Third, transaction processingThe transaction processing of Redis is relatively straightforward. Only the commands in the client-initiated transaction can be guaranteed to execute consecutively, and no other client commands are inserted, and when a client issues the multi command in the connection, the connection enters
As a non-relational database, redis has the same transaction operations with RDBMS, which surprised me. A dedicated file in redis is used to perform transaction-related operations. We can also learn how to implement transaction operations in
Jedis transactionsWhen we use JDBC to connect to MySQL, we need to open the transaction every time we execute the SQL statement; in MyBatis,You also need to use opensession () to get the session transaction object for SQL execution, query, and so on. When weAt the end of the operation on the database, the transaction object is responsible for shutting down the da
In many aspects, Redis is similar to MySQL before InnoDB. Redis adopts a reasonable method to ensure data integrity (such as replication and AOF), and
In many aspects, Redis is similar to MySQL before InnoDB. Redis adopts a reasonable method to ensure data integrity (such as replication and AOF), and
In the past f
It has been several months since reids was studied and used. I have summarized a lot of documents and related materials. In the next time, I will share some relevant materials, this article also describes how to use it in our applications.
The following is an introduction to redis (refer to redis. io ):
I. Use of things
1. Redis transactions start with the MULTI
Redis's current support for transactions is relatively straightforward, and redis guarantees that commands in a client-initiated transaction can be executed consecutively without inserting other client commands; When a client initiates a multi command in a connection, The connection goes into the transaction context, and the subsequent commands are not executed i
ways to implement transactionsmulti (Open transaction) +exec (commit) +discard (Discard transaction) +watch (CAS optimistic lock) Lua script
the characteristics of Redis affairsAll methods in a transaction are executed serially, the execution is not interrupted by another client; the
I. Redis self-with transaction mechanism
Redis transactions are operated through the multi, EXEC, discard, watch, and Unwatch commands, as follows:Open the transaction through the multi, then add any command to the queue, execute the queue command through exec, discard the transac
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.